package com.kuang.dao;

import com.kuang.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

//部门dao
@Repository //这是做什么的?什么是被springboot托管
public class DepartmentDao {
    private static Map<Integer, Department> departments=null;//模拟数据库中的数据
    static {//数据库中的数据
        departments=new HashMap<>();//创建一个部门表
        departments.put(101,new Department(101,"教学部"));
        departments.put(102,new Department(102,"市场部"));
        departments.put(103,new Department(103,"教研部"));
        departments.put(104,new Department(104,"运营部"));
        departments.put(105,new Department(105,"后勤部"));
    }
    public Collection<Department> getDepartments(){ //获得全部部门信息
        return departments.values();
    }
    public static Department getDepartmentById(Integer id){ //通过id得到部门
        return departments.get(id);
    }
    //
}









